package cn.lxh.auto_configure;

import cn.lxh.Interceptor.SaTokenInterceptor;
import cn.lxh.config.RedisConfig;
import cn.lxh.config.SaTokenConfigure;
import cn.lxh.config.StpInterfaceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @author lxh Create Time: 2023/12/26 23:38
 * 自动配置类
 */
@Configuration
@Import({RedisConfig.class, SaTokenConfigure.class})
//@AutoConfigureBefore({RedisConfig.class, SaTokenConfigure.class})
public class SaTokenAutoConfiguration {
    @Bean
    public StpInterfaceImpl stpInterface(RedisTemplate<String, Object> redisTemplate) {
        return new StpInterfaceImpl(redisTemplate);
    }

    @Bean
    public SaTokenInterceptor saTokenInterceptor(){
        return new SaTokenInterceptor();
    }

    @Bean
    public BCryptPasswordEncoder bCryptPasswordEncoder() {
        return new BCryptPasswordEncoder();
    }

}
